const express = require("express");
const path = require("path");
const server = express();
const bodyParser = require('body-parser');

server.set("view engine", "ejs")
server.set("views", path.resolve(__dirname, "static"))
server.use(express.static('static'));
server.use(bodyParser.urlencoded({ extends: false }));

// var list = [{ name }}

server.get("/", (req, res) => {
    res.sendFile(path.join(__dirname + "index.html"));
});
server.get("/add", (req, res) => {
    list = req.query;

    res.render("index", { list })
});
server.post("/add", (req, res) => {
    list = req.query;

    res.render("index", { list })

});
server.listen("3000", () => {
    console.log("http://localhost:3000");
});